<template>
  <div class="add container-content">
      <!-- <el-row>
        <el-col :span="24">
            <h3 class="panel-title">添加商机</h3>
        </el-col>
    </el-row> -->
      <el-form
          ref="formObjectRef"
          :model="formObject"
          label-width="80px"
          :rules="formObjectRules"
          status-icon
      >
          <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
              <el-tab-pane label="基本信息" name="basic">
                  <!-- 客户 -->
                  <div class="desc-title">客户</div>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item
                              label="创建组织"
                              prop=""
                              label-width="110px"
                          >
                              <!-- v-model="formObject.deptId" -->
                              <el-input placeholder="请输入"></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="使用组织"
                              prop=""
                              label-width="110px"
                          >
                              <!-- v-model="formObject.deptId" -->
                              <el-input placeholder="请输入"></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="简称"
                              prop="abbreviation"
                              label-width="110px"
                          >
                              <!-- v-model="formObject.deptId" -->
                              <el-input
                                  placeholder="请输入"
                                  v-model="
                                      formObject.customerEntity.abbreviation
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item
                              label="客户编码"
                              prop=""
                              label-width="110px"
                          >
                              <el-input placeholder="请输入"></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="客户名称"
                              prop="customerName"
                              label-width="110px"
                          >
                              <el-input
                                  placeholder="请输入"
                                  v-model="
                                      formObject.customerEntity.customerName
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <!-- 地址 -->
                  <div class="desc-title">地址</div>
                  <el-row :gutter="2">
                      <el-form-item
                          label="客户地址"
                          prop="country"
                          label-width="110px"
                      >
                          <el-col :span="2">
                              <el-select
                                  v-model="
                                      formObject.customerEntity.provincesId
                                  "
                                  placeholder="省"
                                  @change="getCity"
                              >
                                  <el-option
                                      v-for="item in provinces"
                                      :key="item.id"
                                      :label="item.areaName"
                                      :value="item.id"
                                  >
                                  </el-option>
                              </el-select>
                          </el-col>
                          <el-col :span="2">
                              <el-select
                                  v-model="formObject.customerEntity.cityId"
                                  placeholder="市"
                                  @change="getCounty"
                              >
                                  <el-option
                                      v-for="item in cities"
                                      :key="item.id"
                                      :label="item.areaName"
                                      :value="item.id"
                                  >
                                  </el-option>
                              </el-select>
                          </el-col>
                          <el-col :span="2">
                              <el-select
                                  v-model="formObject.customerEntity.countyId"
                                  placeholder="区/县"
                              >
                                  <el-option
                                      v-for="item in counties"
                                      :key="item.id"
                                      :label="item.areaName"
                                      :value="item.id"
                                  >
                                  </el-option>
                              </el-select>
                          </el-col>
                          <el-col :span="18">
                              <el-input
                                  placeholder="详细地址"
                                  v-model="formObject.address"
                              ></el-input>
                          </el-col>
                      </el-form-item>
                  </el-row>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="邮政编码" label-width="110px">
                              <el-input
                                  placeholder="邮政编码"
                                  v-model="formObject.customerEntity.postCode"
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="公司网址" label-width="110px">
                              <el-input
                                  placeholder="公司网址"
                                  v-model="
                                      formObject.customerEntity.companyUrl
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <!-- 管理 -->
                  <div class="desc-title">管理</div>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="联系电话" label-width="110px">
                              <el-input
                                  placeholder="联系电话"
                                  v-model="formObject.customerEntity.telPhone"
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="传真" label-width="110px">
                              <el-input
                                  placeholder="传真"
                                  v-model="
                                      formObject.customerEntity.facsimile
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="公司类别" label-width="110px">
                              <el-input
                                  placeholder="公司类别"
                                  v-model="
                                      formObject.customerEntity.companyType
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="公司性质" label-width="110px">
                              <el-input
                                  placeholder="公司性质"
                                  v-model="
                                      formObject.customerEntity.companyNature
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="公司规模" label-width="110px">
                              <el-input
                                  placeholder="公司规模"
                                  v-model="
                                      formObject.customerEntity.companySize
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <!-- 注册 -->
                  <div class="desc-title">注册</div>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="法人代表" label-width="110px">
                              <el-input
                                  placeholder="法人代表"
                                  v-model="
                                      formObject.customerEntity
                                          .legalRepresentative
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="注册资本" label-width="110px">
                              <el-input
                                  placeholder="注册资本"
                                  v-model="
                                      formObject.customerEntity
                                          .registeredCapital
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="创立日期" label-width="110px">
                              <el-input
                                  placeholder="创立日期"
                                  v-model="
                                      formObject.customerEntity.registeredTime
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="行业" label-width="110px">
                              <el-input
                                  placeholder="行业"
                                  v-model="formObject.customerEntity.industry"
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="注册地址" label-width="110px">
                              <el-input
                                  placeholder="注册地址"
                                  v-model="
                                      formObject.customerEntity
                                          .registerAddress
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <!-- 开票信息 -->
                  <div class="desc-title">开票信息</div>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="发票抬头" label-width="110px">
                              <el-input
                                  placeholder="发票抬头"
                                  v-model="
                                      formObject.customerEntity.invoiceHeader
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="纳税登记号"
                              label-width="110px"
                          >
                              <el-input
                                  placeholder="纳税登记号"
                                  v-model="formObject.customerEntity.taxId"
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="开户银行" label-width="110px">
                              <el-input
                                  placeholder="开户银行"
                                  v-model="formObject.customerEntity.openBank"
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="银行账号" label-width="110px">
                              <el-input
                                  placeholder="银行账号"
                                  v-model="
                                      formObject.customerEntity.bankAccount
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="开票联系电话"
                              label-width="110px"
                          >
                              <el-input
                                  placeholder="开票联系电话"
                                  v-model="
                                      formObject.customerEntity.invoiceHotline
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="税号" label-width="110px">
                              <el-input
                                  placeholder="税号"
                                  v-model="
                                      formObject.customerEntity.unifiedCode
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="10">
                      <el-col :span="24">
                          <el-form-item
                              label="开票通讯地址"
                              label-width="108px"
                          >
                              <el-input
                                  placeholder="开票通讯地址"
                                  v-model="
                                      formObject.customerEntity.invoiceAddress
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <!-- 相关 -->
                  <div class="desc-title">相关</div>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item label="客户类别" label-width="110px">
                              <el-input
                                  placeholder="客户类别"
                                  v-model="
                                      formObject.customerEntity.customerType
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="客户分组" label-width="110px">
                              <el-input
                                  placeholder="客户分组"
                                  v-model="
                                      formObject.customerEntity.customerGroup
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="对应组织" label-width="110px">
                              <el-input
                                  placeholder="对应组织"
                                  v-model="
                                      formObject.customerEntity.counterDept
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="10">
                      <el-col :span="8">
                          <el-form-item
                              label="对应供应商"
                              label-width="110px"
                          >
                              <el-input
                                  placeholder="对应供应商"
                                  v-model="
                                      formObject.customerEntity
                                          .counterSupplier
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="对应集团客户"
                              label-width="110px"
                          >
                              <el-input
                                  placeholder="对应集团客户"
                                  v-model="
                                      formObject.customerEntity
                                          .counterCustomerId
                                  "
                              ></el-input>
                              <!-- <el-checkbox-group v-model="">
                              <el-checkbox label="集团客户" name="type"></el-checkbox>
                              <el-checkbox label="默认付款方" name="type"></el-checkbox>
                              <el-checkbox label="不校验可发量" name="type"></el-checkbox>
                            </el-checkbox-group> -->
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row>
                      <el-col :span="24">
                          <el-form-item label="备注" label-width="110px">
                              <el-input
                                  type="textarea"
                                  v-model="formObject.customerEntity.remarks"
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <!-- 智慧订货 -->
                  <div class="desc-title">智慧订货</div>
                  <el-row>
                      <el-col :span="8">
                          <el-form-item
                              label="是否允许对接智慧订货"
                              label-width="164px"
                          >
                              <el-radio-group
                                  v-model="formObject.isAllow"
                                  size="mini"
                              >
                                  <el-radio
                                      label="是"
                                      :v-model="1"
                                      border
                                  ></el-radio>
                                  <el-radio
                                      label="否"
                                      :v-model="2"
                                      border
                                  ></el-radio>
                              </el-radio-group>
                          </el-form-item>
                      </el-col>
                  </el-row>
              </el-tab-pane>
              <el-tab-pane label="联系人" name="more">
                  <el-table
                      :data="formObject.contactsEntities"
                      style="width: 100%"
                      highlight-current-row
                      border
                  >
                      <template #empty>
                          <el-button
                              plain
                              type="primary"
                              round
                              size="mini"
                              @click="addNewRow('contact')"
                              >添加新行
                          </el-button>
                      </template>
                      <el-table-column label="操作" width="120">
                          <template slot-scope="scope">
                              <el-button
                                  plain
                                  icon="el-icon-plus"
                                  size="mini"
                                  @click="
                                      handleDataAdd(scope.$index, scope.row)
                                  "
                              ></el-button>
                              <el-button
                                  plain
                                  icon="el-icon-minus"
                                  size="mini"
                                  @click="
                                      handleDataDelete(
                                          scope.$index,
                                          scope.row
                                      )
                                  "
                              ></el-button>
                          </template>
                      </el-table-column>
                      <el-table-column label="编码">
                          <template slot-scope="scope">
                              <el-input v-model="scope.row.code"></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="姓名" width="150">
                          <template slot-scope="scope">
                              <el-form-item
                                  prop="name"
                                  label-width="0px"
                                  style="margin: 0"
                              >
                                  <el-input
                                      v-model="scope.row.name"
                                  ></el-input>
                              </el-form-item>
                          </template>
                      </el-table-column>
                      <el-table-column label="性别" width="120">
                          <template slot-scope="scope">
                              <el-radio-group
                                  v-model="scope.row.sex"
                                  size="small"
                              >
                                  <el-radio label="男">男</el-radio>
                                  <el-radio label="女">女</el-radio>
                              </el-radio-group>
                          </template>
                      </el-table-column>
                      <el-table-column label="职位">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.position"
                                  @change="
                                      positionChange(
                                          scope.row.position,
                                          scope.$index
                                      )
                                  "
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="手机">
                          <template slot-scope="scope">
                              <el-input v-model="scope.row.phone"></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="电话">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.tel"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="邮箱">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.email"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="传真">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.facsimile"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="地点编码">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.addressCode"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="地点名称">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.address"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="详细地址">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.detailAddress"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column label="默认收货地址">
                          <template slot-scope="scope">
                              <el-radio-group
                                  v-model="scope.row.isDefault"
                                  size="small"
                              >
                                  <el-radio label="是">是</el-radio>
                                  <el-radio label="否">否</el-radio>
                              </el-radio-group>
                          </template>
                      </el-table-column>
                  </el-table>
              </el-tab-pane>
              <el-tab-pane label="商务信息" name="business">
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item label="结算币别" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .settlementCurrency
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="销售部门" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .salesDept
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="销售组" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .salesGroup
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item label="销售员" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .salesId
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="冻结状态" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .frozenState
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="冻结范围" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .frozenScope
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item label="冻结人" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .frozenBy
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="冻结日期" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .frozenTime
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="保证金比例（%）"
                              label-width="130px"
                          >
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .marginRatio
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item label="结算卡" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .settlementCard
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="结算方" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .settlementPartyId
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="付款方" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation.payId
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item
                              label="默认联系人"
                              label-width="130px"
                          >
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .defaultContacts
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="结算方式" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .settlementMethod
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="收款条件" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .paymentTerms
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item label="价目表" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .priceId
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="折扣表" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .discountId
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="联系人必录"
                              label-width="130px"
                          >
                              <el-radio label="1" border>是</el-radio>
                              <el-radio label="2" border>否</el-radio>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item label="发票类型" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .invoiceType
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item label="默认税率" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .defaultTaxRate
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="运输提前期"
                              label-width="130px"
                          >
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .transLeadTime
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                  </el-row>
                  <el-row :gutter="20">
                      <el-col :span="8">
                          <el-form-item label="税分类" label-width="130px">
                              <el-input
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .taxClass
                                  "
                              ></el-input>
                          </el-form-item>
                      </el-col>
                      <el-col :span="8">
                          <el-form-item
                              label="启用信用管理"
                              label-width="130px"
                          >
                              <el-radio-group
                                  v-model="
                                      formObject.erpBusinessInformation
                                          .isCreditAgency
                                  "
                              >
                                  <el-radio label="1" border>是</el-radio>
                                  <el-radio label="2" border>否</el-radio>
                              </el-radio-group>
                          </el-form-item>
                      </el-col>
                  </el-row>
              </el-tab-pane>
              <el-tab-pane label="银行信息" name="bank">
                  <el-table
                      :data="formObject.bankEntities"
                      style="width: 100%"
                      highlight-current-row
                      border
                  >
                      <template #empty>
                          <el-button
                              plain
                              type="primary"
                              round
                              @click="addNewRow('bank')"
                              >添加新行
                          </el-button>
                      </template>
                      <el-table-column label="操作" width="120">
                          <template slot-scope="scope">
                              <el-button
                                  plain
                                  icon="el-icon-plus"
                                  size="mini"
                                  @click="
                                      handleDataAdd_bank(
                                          scope.$index,
                                          scope.row
                                      )
                                  "
                              ></el-button>
                              <el-button
                                  plain
                                  icon="el-icon-minus"
                                  size="mini"
                                  @click="
                                      handleDataDelete_bank(
                                          scope.$index,
                                          scope.row
                                      )
                                  "
                              ></el-button>
                          </template>
                      </el-table-column>
                      <el-table-column
                          prop="isDefault"
                          label="默认"
                          width="50"
                          align="center"
                      >
                          <template slot-scope="scope">
                              <el-checkbox
                                  v-model="scope.row.isDefault"
                              ></el-checkbox>
                          </template>
                      </el-table-column>
                      <el-table-column prop="openingCountry" label="开户国家">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.openingCountry"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="bankAccount" label="银行账号">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.bankAccount"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="accountName" label="账户名称">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.accountName"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="dueBanke" label="收款银行">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.dueBanke"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="brancheName" label="网点名称">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.brancheName"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="bankBranches" label="银行网点">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.bankBranches"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column
                          prop="openBankAddress"
                          label="开户行地址"
                      >
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.openBankAddress"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="bankName" label="开户银行">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.bankName"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="unionPayAccount" label="联行号">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.unionPayAccount"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="currency" label="币别">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.currency"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                  </el-table>
              </el-tab-pane>
              <el-tab-pane label="地址信息" name="adress">
                  <el-table
                      :data="formObject.addresses"
                      style="width: 100%"
                      border
                  >
                      <template #empty>
                          <el-button
                              plain
                              type="primary"
                              round
                              @click="addNewRow('address')"
                              >添加新行
                          </el-button>
                      </template>
                      <el-table-column label="操作" width="120">
                          <template slot-scope="scope">
                              <el-button
                                  plain
                                  icon="el-icon-plus"
                                  size="mini"
                                  @click="
                                      handleDataAdd_address(
                                          scope.$index,
                                          scope.row
                                      )
                                  "
                              ></el-button>
                              <el-button
                                  plain
                                  icon="el-icon-minus"
                                  size="mini"
                                  @click="
                                      handleDataDelete_address(
                                          scope.$index,
                                          scope.row
                                      )
                                  "
                              ></el-button>
                          </template>
                      </el-table-column>
                      <el-table-column prop="addressCode" label="地点编码">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.addressCode"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="addressName" label="地点名称">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.addressName"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="detilAddress" label="详细地址">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.detilAddress"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column
                          prop="transLeadTime"
                          label="运输提前期"
                      >
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.transLeadTime"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="contacts" label="联系人">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.contacts"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="fixedPhone" label="固定电话">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.fixedPhone"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="phone" label="移动电话">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.phone"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column prop="email" label="电子邮箱">
                          <template slot-scope="scope">
                              <el-input
                                  v-model="scope.row.email"
                                  clearable
                              ></el-input>
                          </template>
                      </el-table-column>
                      <el-table-column
                          prop="isDefaltAddress"
                          label="默认收货地址"
                          width="60"
                          align="center"
                      >
                          <template slot-scope="scope">
                              <el-checkbox
                                  v-model="scope.row.isDefaltAddress"
                              ></el-checkbox>
                          </template>
                      </el-table-column>
                      <el-table-column
                          prop="isDefaultBillAddress"
                          label="默认开票地址"
                          width="60"
                          align="center"
                      >
                          <template slot-scope="scope">
                              <el-checkbox
                                  v-model="scope.row.isDefaultBillAddress"
                              ></el-checkbox>
                          </template>
                      </el-table-column>
                      <el-table-column
                          prop="isDefaultPayAddress"
                          label="默认付款地址"
                          width="60"
                          align="center"
                      >
                          <template slot-scope="scope">
                              <el-checkbox
                                  v-model="scope.row.isDefaultPayAddress"
                              ></el-checkbox>
                          </template>
                      </el-table-column>
                      <el-table-column
                          prop="isUsed"
                          label="启用"
                          width="60"
                          align="center"
                      >
                          <template slot-scope="scope">
                              <el-checkbox
                                  v-model="scope.row.isUsed"
                              ></el-checkbox>
                          </template>
                      </el-table-column>
                      <el-table-column prop="" label="地址禁用状态">
                          <template slot-scope="scope">
                              <p v-if="scope.row.isUsed">是</p>
                              <p v-else>是</p>
                          </template>
                      </el-table-column>
                  </el-table>
              </el-tab-pane>
          </el-tabs>
          <!-- <el-form-item label-width="0px" style="margin-top: 20px">
            <el-button
                type="primary"
                size="medium"
                @click="formSubmit('basicFormRef')"
            >保存
            </el-button
            >
            <el-button size="medium" @click="formRest('basicFormRef')"
            >取消
            </el-button
            >
        </el-form-item> -->
      </el-form>
  </div>
</template>
<script>
import { editCustomerList, getDetailCustomer } from "@/api/system/customer";
import { getAreaList } from "@/api/area/area";

export default {
  props: ["id"],
  data() {
      return {
          activeName: "basic",
          formObject: {
              customerEntity: {
                  abbreviation: "", //简称
                  customerName: "", //客户名称
                  provincesId: "", //省
                  cityId: "", //市
                  countyId: "", //区
                  address: "", //详细地址
                  postCode: "", //邮政编码
                  companyUrl: "", //公司网址
                  telPhone: "", //联系电话
                  facsimile: "", //传真
                  companyType: "", //公司类别
                  companyNature: "", //公司性质
                  companySize: "", //公司规模
                  legalRepresentative: "", //法人代表
                  registeredCapital: "", //注册资本
                  registeredTime: "", //创立日期
                  industry: "", //行业
                  registerAddress: "", //注册地址
                  invoiceHeader: "", //开票抬头
                  taxId: "", //纳税登记号
                  openBank: "", //开户银行
                  bankAccount: "", //银行账号
                  invoiceHotline: "", //开票联系电话
                  invoiceAddress: "", //开票地址
                  unifiedCode: "", //统一社会信用代码
                  customerType: "", //客户类别
                  customerGroup: "", //客户分组
                  counterDept: "", //对应组织
                  counterSupplier: "", //对应供应商
                  counterCustomerId: "", //对应集团客户
                  remarks: "", //备注
                  isAllow: "", //是否允许智慧订货
                  type: 2,
              },
              erpBusinessInformation: {
                  settlementCurrency: "", //结算币别
                  salesDept: "", //销售部门
                  salesGroup: "", //销售组
                  salesId: "", //销售员
                  frozenState: "", //冻结状态
                  frozenScope: "", //冻结范围
                  frozenBy: "", //冻结人
                  frozenTime: "", //冻结日期
                  marginRatio: "", //保证金比例
                  settlementCard: "", //结算卡
                  settlementPartyId: "", //结算方
                  payId: "", //付款方
                  defaultContacts: "", //默认联系人
                  settlementMethod: "", //结算方式
                  paymentTerms: "", //收款条件
                  priceId: "", //价目表
                  discountId: "", //折扣表
                  defaultContacts: "", //默认联系人
                  invoiceType: "", //发票类型
                  defaultTaxRate: "", //默认税率
                  transLeadTime: "", //运输提前期
                  taxClass: "", //税分类
                  isCreditAgency: "", //启用信用管理
              },
              contactsEntities: [
                  {
                      address: "", //地点名称
                      addressCode: "", //地点编码
                      detailAddress: "", //详细地址
                      email: "", //邮箱
                      facsimile: "", //传真
                      tel: "", //固定电话
                      phone: "", //移动电话
                      name: "", //姓名
                      position: "", //职务
                      isDefault: "", //是否默认收货地址
                      company: "", //所属公司
                      sex: "", //性别
                  },
              ],
              bankEntities: [
                  {
                      openingCountry: "", //开户国家
                      bankAccount: "", //银行账号
                      accountName: "", //账户名称
                      dueBanke: "", //收款银行
                      brancheName: "", //网点名称
                      bankBranches: "", //银行网点
                      openBankAddress: "", //开户行地址
                      bankName: "", //开户银行
                      unionPayAccount: "", //联行号
                      currency: "", //币别
                      isDefault: "", //是否默认
                  },
              ],
              addresses: [
                  {
                      addressCode: "", //地点编码
                      addressName: "", //地点名称
                      detilAddress: "", //详细地址
                      transLeadTime: "", //运输提前期
                      contacts: "", //联系人
                      fixedPhone: "", //固定电话
                      phone: "", //移动电话
                      email: "", //邮箱
                      isDefaltAddress: "", //默认收货地址
                      isDefaultBillAddress: "", //默认开票地址
                      isDefaultPayAddress: "", //默认付款地址
                      isUsed: "", //启用 地址禁用状态
                  },
              ],
          },
          provinces: [],
          cities: [],
          counties: [],
          formObjectRules: {
              // customerName: [
              //   { required: true, message: "客户名称不能为空！", trigger: "blur" },
              // ],
              // name: [
              //   { required: true, message: "联系人姓名不能为空！", trigger: "blur" },
              // ],
          },
      };
  },
  methods: {
      // 页签切换事件
      handleClick(tab, event) {
          console.log(tab, event);
      },
      // 附件上传
      handleFileChange() {
          console.log("文件上传");
      },

      // 基础表单提交
      formSubmit() {
          this.editCustomerList(this.formObject).then((res) => {
              if (res.code === 200) {
                  this.$message({
                      message: "修改成功！",
                      type: "success",
                  });
              }
          });
      },
      // 基础表单取消
      formRest(basicFormRef) {
          this.$refs[basicFormRef].resetFields();
      },
      // 更多联系人表单 添加行
      handleDataAdd() {
          if (this.formObject.contactsEntities == undefined) {
              this.formObject.contactsEntities = [];
          }
          let obj = {};
          obj.address = "";
          obj.addressCode = "";
          obj.email = "";
          obj.facsimile = "";
          obj.email = "";
          obj.tel = "";
          obj.phone = "";
          obj.name = "";
          obj.position = "";
          obj.isDefault = "";
          obj.company = "";
          obj.sex = "";
          this.formObject.contactsEntities.push(obj);
      },
      // 更多联系人表单 删除行
      handleDataDelete(index, row) {
          this.$confirm("请确认是否要删除此行？", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  this.$message({
                      type: "success",
                      message: "删除成功!",
                  });
                  this.formObject.contactsEntities.splice(index, 1);
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "已取消删除",
                  });
              });
      },
      //银行信息表单 添加行
      handleDataAdd_bank() {
          if (this.formObject.bankEntities == undefined) {
              this.formObject.bankEntities = [];
          }
          let obj = {};
          obj.openingCountry = "";
          obj.bankAccount = "";
          obj.accountName = "";
          obj.dueBanke = "";
          obj.brancheName = "";
          obj.bankBranches = "";
          obj.openBankAddress = "";
          obj.bankName = "";
          obj.unionPayAccount = "";
          obj.currency = "";
          obj.isDefault = "";
          this.formObject.bankEntities.push(obj);
      },
      //银行信息表单 删除行
      handleDataDelete_bank(index, row) {
          this.$confirm("请确认是否要删除此行?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  this.formObject.bankEntities.splice(index, 1);
                  this.$message({
                      type: "success",
                      message: "删除成功!",
                  });
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "已取消删除",
                  });
              });
      },
      //地址表单 添加行
      handleDataAdd_address() {
          if (this.formObject.addresses == undefined) {
              this.formObject.addresses = [];
          }
          let obj = {};
          obj.addressCode = "";
          obj.addressName = "";
          obj.detilAddress = "";
          obj.transLeadTime = "";
          obj.contacts = "";
          obj.fixedPhone = "";
          obj.phone = "";
          obj.email = "";
          obj.isDefaltAddress = "";
          obj.isDefaultBillAddress = "";
          obj.isDefaultPayAddress = "";
          obj.isUsed = "";
          this.formObject.addresses.push(obj);
      },
      //银行信息表单 删除行
      handleDataDelete_address(index, row) {
          this.$confirm("请确认是否要删除此行?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
          })
              .then(() => {
                  this.formObject.addresses.splice(index, 1);
                  this.$message({
                      type: "success",
                      message: "删除成功!",
                  });
              })
              .catch(() => {
                  this.$message({
                      type: "info",
                      message: "已取消删除",
                  });
              });
      },
      //添加新行
      addNewRow(type) {
          if (type === "address") {
              this.handleDataAdd_address();
          } else if (type === "bank") {
              this.handleDataAdd_bank();
          } else {
              this.handleDataAdd();
          }
      },
      //默认获取省列表
      getProvince(parentId) {
          // 查询省份
          getAreaList({ parentId: parentId }).then((res) => {
              this.provinces = res.rows;
          });
      },
      //点击省份获取城市列表
      getCity(parentId) {
          this.formObject.customerEntity.cityId = "";
          this.formObject.customerEntity.countyId = "";
          this.counties = [];
          // 查询省份
          getAreaList({ parentId: parentId }).then((res) => {
              this.cities = res.rows;
          });
      },
      //点击城市获取区县列表
      getCounty(parentId) {
          this.formObject.customerEntity.countyId = "";
          // 查询省份
          getAreaList({ parentId: parentId }).then((res) => {
              this.counties = res.rows;
          });
      },
      getData(id) {
          getDetailCustomer(id).then((res) => {
              this.formObject.customerEntity = res.data;
          });
      },
  },
  created() {
      // 查询中国下属省份
      this.getProvince("20230705392153575054249984");
      this.getData(this.id);
  },
};
</script>
<style lang="scss" scoped>
// .add {
//   padding: 15px;
// }
.panel-title {
  font-size: 18px;
  color: #37474f;
  font-weight: 500;
  text-shadow: rgba(0, 0, 0, 0.15) 0 0 1px;
}

::v-deep .el-form-item__content {
  margin-left: 0;
}

.main-responsible {
  font-size: 14px;
  font-weight: 550;
  color: #263238;
  position: relative;
  text-indent: 15px;
}
</style>
